import logging
import time

from selenium.webdriver.common.by import By


from Base.Base import Base


class Page(Base):
    #点击请登录 文本
    login=(By.LINK_TEXT,'请登录')
    #账号款 id="userName"
    name=(By.ID,'userName')
    #密码框 id="password"
    password=(By.ID,'password')
    #登录按钮 id="save"
    save=(By.ID,'save')
    #点击确认  id="bindSub"
    bindSub=(By.ID,'bindSub')
    #点击我的酒仙
    sbumit=(By.XPATH,'/html/body/div[2]/div/div[2]/ul/li[1]/div[1]/a')
    #窗口切换技术
    #下滑
    #点击收货地址
    add=(By.XPATH,'/html/body/div[4]/div[1]/div[2]/div[4]/a[3]/span')
    #收入地址 id="people"
    username=(By.ID,'people')
    #地区 id="province" value="2"
    province=(By.ID,'province')
    #市 name="city" index 1
    shi=(By.NAME,'city')
    #区 id="district" text东城区
    district=(By.ID,'district')
    #输入地址 id="address"
    address=(By.ID,'address')
    #邮政编号 name="zipcode"
    zipcode=(By.NAME,'zipcode')
    #手机 id="iphone"
    iphone=(By.ID,'iphone')
    #提交 class="qjwSubmit2"
    qjwSubmit2=(By.CLASS_NAME,'qjwSubmit2')
    #确认
    quer=(By.XPATH,'/html/body/div[8]/div/div[3]/span[1]/b')


    #登录
    def login1(self,username):
        self.click(self.login)
        self.send_keys(self.name,username)
    def login2(self,password):
        self.send_keys(self.password,password)
        time.sleep(10)
        self.click(self.save)
        time.sleep(5)
        # self.click(self.bindSub)
        # time.sleep(5)



    #点击我的酒仙并实现技术模块
    def add1(self):
        # 点击我的酒仙
        self.click(self.sbumit)
        time.sleep(10)
        # #窗口切换技术
        self.window()
        # 下滑
        self.execute_script(500)
        # 点击收货地址
        self.click(self.add)
        # 收入地址 id="people"
        self.send_keys(self.username,'喜洋洋')
        #键盘事件
        self.key(self.username,'c')
        #地区
        self.select(self.province,'2')
        #市
        self.select1(self.shi,1)
        #区
        self.select2(self.district,'东城区')
        #地址
        self.send_keys(self.address,'北京八维喜洋洋学院')
        #键盘事件
        # self.key(self.address, 'v')
        #邮政编号
        self.send_keys(self.zipcode,'123456')
        #输入手机号
        self.send_keys(self.iphone,'18696472856')
        #提交按钮
        self.click(self.qjwSubmit2)
        #确认按钮
        self.click(self.quer)


    def jiuxiang_luoji(self):
        logging.info('调用页面元素')
        self.add1()
        time.sleep(5)





